' Press Page Down for information on running and modifying QBlocks.
'
' To run this game, press Shift+F5.
'
' To exit this program, press ALT, F, X.
'
' To get help on a BASIC keyword, move the cursor to the keyword and press
' F1 or click the right mouse button.
'
' Suggested Changes
' -----------------
'
' There are many ways that you can modify this BASIC game. The CONST
' statements below these comments and the DATA statements at the end
' of this screen can be modified to change the following:
'
' Block shapes
' Block rotation
' Number of different block shapes
' Score needed to advance to next level
' Width of the game well
' Height of the game well
' Songs played during game
'
' On the right side of each CONST statement, there is a comment that tells
' you what it does and how big or small you can set the value. Above the
' DATA statements, there are comments that tell you the format of the
' information stored there.
'
' On your own, you can also add exciting sound and visual effects or make any
' other changes that your imagination can dream up. By reading the
' Learn BASIC Now book, you'll learn the techniques that will enable you
' to fully customize this game and to create games of your own.
'
' If the game won't run after you have changed it, you can exit without
' saving your changes by pressing Alt, F, X and choosing NO.
'
' If you do want to save your changes, press Alt, F, A and enter a filename
' for saving your version of the program. Before you save your changes,
' however, you should make sure they work by running the program and
' verifying that your changes produce the desired results. Also, always
' be sure to keep a backup of the original program.
'
DEFINT A-Z
' Here are the BASIC CONST statements you can change. The comments tell
' you the range that each CONST value can be changed, or any limitations.
CONST WELLWIDTH = 10 ' Width of playing field (well). Range 5 to 13.
CONST WELLHEIGHT = 21 ' Height of playing field. Range 4 to 21.
CONST NUMSTYLES = 7 ' Number of unique shapes. Range 1 to 20. Make sure you read the notes above the DATA statements at the end of the main program before you change this number!
CONST WINGAME = 1000000 ' Points required to win the game. Range 200 to 9000000.
CONST NEXTLEVEL = 300 ' Helps determine when the game advances to the next level. (Each cleared level gives player 100 points) Range 100 to 2000.
CONST BASESCORE = 1000 ' Number of points needed to advance to first level.
CONST ROTATEDIR = 1 ' Control rotation of blocks. Can be 1 for clockwise, or 3 for counterclockwise.
' The following sound constants are used by the PLAY command to
' produce music during the game. To change the sounds you hear, change
' these constants. Refer to the online help for PLAY for the correct format.
' To completely remove sound from the game set the constants equal to null.
' For example: PLAYINTRO = ""
CONST PLAYCLEARROW = "MBT255L16O4CDEGO6C" ' Tune played when a row is cleared. Range unlimited.
CONST PLAYINTRO = "MBT170O1L8CO2CO1CDCA-A-FGFA-F" ' Song played at game start. Range unlimited.
CONST PLAYGAMEOVER = "MBT255L16O6CO4GEDC" ' Song when the game is lost. Range unlimited.
CONST PLAYNEWBLOCK = "MBT160L28N20L24N5" ' Song when a new block is dropped. Range unlimited.
CONST PLAYWINGAME = "T255L16O6CO4GEDCCDEFGO6CEG" ' Song when game is won. Range unlimited.
' The following CONST statements should not be changed like the ones above
' because the program relies on them being this value.
CONST FALSE = 0 ' 0 means FALSE.
CONST TRUE = NOT FALSE ' Anything but 0 can be thought of as TRUE.
CONST SPACEBAR = 32 ' ASCII value for space character. Drops the shape.
CONST DOWNARROW = 80 ' Down arrow key. Drops the shape.
CONST RIGHTARROW = 77 ' Right arrow key. Moves the shape right.
CONST UPARROW = 72 ' Up arrow key. Rotates the shape.
CONST LEFTARROW = 75 ' Left arrow key. Moves the shape left.
CONST XMATRIX = 3 ' Width of the matrix that forms each falling unit. See the discussions in Suggested Changes #2 and #3.
CONST YMATRIX = 1 ' Depth of the matrix that forms each falling unit.
CONST BYTESPERBLOCK = 76 ' Number of bytes required to store one block in Screen mode 7.
CONST BLOCKVOLUME = (XMATRIX + 1) * (YMATRIX + 1) ' Number of blocks in each shape.
CONST ELEMENTSPERBLOCK = BLOCKVOLUME * BYTESPERBLOCK \ 2 ' Number of INTEGER array elements needed to store an image of a shape.
CONST XSIZE = 13 ' Width, in pixels, of each block. QBlocks assumes that the entire screen is 25 blocks wide. Since the screen is 320 pixels wide, each block is approximately 13 pixels wide.
CONST YSIZE = 8 ' Height, in pixels, of each block. Again, QBlocks assumes that screen is 25 blocks high. At 200 pixels down, each block is exactly 8 pixels high.
CONST XOFFSET = 10 ' X position, in blocks, of the well.
CONST YOFFSET = 2 ' Y position, in blocks, of the well.
CONST WELLX = XSIZE * XOFFSET ' X position, in pixels, of the start of the well.
CONST WELLY = YSIZE * YOFFSET ' Y position.
CONST TILTVALUE = 9999000 ' Points required for QBlocks to tilt.
CONST WELLCOLOR7 = 0 ' Well color for SCREEN 7.
CONST WELLCOLOR1 = 0 ' Well color for SCREEN 1.
CONST BORDERCOLOR1 = 8 ' Border color for SCREEN 1.
CONST BORDERCOLOR7 = 15 ' Border color for SCREEN 7.
TYPE BlockType ' Block datatype.
X AS INTEGER ' Horizontal location within the well.
Y AS INTEGER ' Vertical location within the well.
Style AS INTEGER ' Define shape (and color, indirectly).
Rotation AS INTEGER ' 4 possible values (0 to 3).
END TYPE
' SUB and FUNCTION declarations
DECLARE FUNCTION CheckFit ()
DECLARE FUNCTION GameOver ()
DECLARE SUB AddBlockToWell ()
DECLARE SUB CheckForFullRows ()
DECLARE SUB Center (M$, Row)
DECLARE SUB DeleteChunk (Highest%, Lowest%)
DECLARE SUB DisplayIntro ()
DECLARE SUB DisplayGameTitle ()
DECLARE SUB DisplayChanges ()
DECLARE SUB DrawBlock (X, Y, FillColor)
DECLARE SUB InitScreen ()
DECLARE SUB MakeInfoBox ()
DECLARE SUB NewBlock ()
DECLARE SUB PerformGame ()
DECLARE SUB RedrawControls ()
DECLARE SUB Show (b AS BlockType)
DECLARE SUB UpdateScoring ()
DECLARE SUB PutBlock (b AS BlockType)
DECLARE SUB DrawAllShapes ()
DECLARE SUB DrawPattern (Patttern)
DECLARE SUB DrawPlayingField ()
' DIM SHARED indicates that a variable is available to all subprograms.
' Without this statement, a variable used in one subprogram cannot be
' used by another subprogram or the main program.
DIM SHARED Level AS INTEGER ' Difficulty level. 0 is slowest, 9 is fastest.
DIM SHARED WellBlocks(WELLWIDTH, WELLHEIGHT) AS INTEGER ' 2 dimensional array to hold the falling shapes that have stopped falling and become part of the well.
DIM SHARED CurBlock AS BlockType ' The falling shape.
DIM SHARED BlockShape(0 TO XMATRIX, 0 TO YMATRIX, 1 TO NUMSTYLES) ' Holds the data required to make each shape. Values determined by the DATA statements at the end of this window.
DIM SHARED PrevScore AS LONG ' Holds the previous level for scoring purposes.